<template>
  <div class="app-container p-rel">
    <div class="container-title">查询</div>
    <el-form :model="queryParams"   ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="85px">
      <el-row :gutter="15">
        <el-col :lg="8" :xl="6">
          <el-form-item label="姓名" prop="name">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入姓名"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="身份证号" prop="identityNumber">
            <el-input
              v-model="queryParams.identityNumber"
              placeholder="请输入身份证号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="健康证号" prop="certificateNumber">
            <el-input
              v-model="queryParams.certificateNumber"
              placeholder="请输入健康证号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
            <el-button type="primary" icon="" size="" @click="handleQuery">搜索</el-button>
            <el-button icon="" size="" @click="resetQuery">重置</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-table v-loading="loading" :data="healthyList">
      <el-table-column type="index" width="55" align="center" label="序号"/>
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="身份证号码" align="center" prop="identityNumber" />
      <el-table-column label="健康证号" align="center" prop="certificateNumber" />
      <el-table-column label="单位名称" align="center" prop="enterpriseName" />
      <el-table-column label="健康证发放时间" align="center" prop="distributionTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.distributionTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listHealthy } from "@/api/zhangping/healthy";

export default {
  name: "Healthy",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 健康证件表格数据
      healthyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        identityNumber: null,
        certificateNumber: null,
        enterpriseName: null,
        creditCode: null,
        distributionTime: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      detailForm:{},
      isEdit:false,
      editVisible:false,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询健康证件列表 */
    getList() {
      this.loading = true;
      listHealthy(this.queryParams).then(response => {
        this.healthyList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        identityNumber: null,
        certificateNumber: null,
        enterpriseName: null,
        creditCode: null,
        distributionTime: null,
        createId: null,
        createBy: null,
        createTime: null,
        updateId: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
